Throws

annotation class Throws(exceptionClasses: KClass<out Throwable>)

This annotation indicates what exceptions should be declared by a function when compiled to a JVM method.

Example:

@Throws(IOException::class)
fun readFile(name: String): String {...}

will be translated to

String readFile(String name) throws IOException {...}

Constructors

Throws
Link copied to clipboard
fun Throws(vararg exceptionClasses: KClass<out Throwable>)

Properties

exceptionClasses
Link copied to clipboard
val exceptionClasses: Array<out KClass<out Throwable>>

the list of checked exception classes that may be thrown by the function.